﻿using EasyLucky.Dal.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EasyLucky.Dal.Dal
{
    public class UserDal:BaseDal
    {
        public List<UserEntity> QueryAll()
        {
            var db = GetClient();
            var Users = db.Queryable<UserEntity>().ToList();
            return Users;
        }

        public int AddUser(UserEntity User)
        {
            var db = GetClient();
            int id = db.Insertable<UserEntity>(User).ExecuteReturnIdentity();
            return id;
        }

        public int DeleteUser(UserEntity User)
        {
            var db = GetClient();
            int cnt = db.Deleteable<UserEntity>(User.Id).ExecuteCommand();
            return cnt;
        }

        public int UpdateUser(UserEntity User)
        {
            var db = GetClient();
            int cnt = db.Updateable<UserEntity>(User).ExecuteCommand();
            return cnt;
        }
    }
}
